::Author:Dzlua
::QQ:505544956
::Time:2017/03/12
@echo off

::支持参数 ansi,debug,static,表示使用的spdui库的类型

if "%1"=="r" goto RUN

::编译所有的demos
:BUILD
set files=*.exe

set mod=release
set unicode=true
set shared=true
for %%c in (%1,%2,%3) do (
    if "%%c"=="debug" set "mod=debug"
    if "%%c"=="ansi" set "unicode=false"
    if "%%c"=="static" set "shared=false"
)

::del files.
for /R "out/bin" %%s in (%files%) do del %%s /q
for /R "build" %%s in (%files%) do del %%s /q

::编译
xmake f -m %mod% --spdui-unicode=%unicode% --spdui-shared=%shared% -F demos.lua
xmake -r -F demos.lua

::复制
for /R "build" %%f in (%files%) do copy %%f "out/bin/%%~nxf"

::复制hello资源到out/bin
xcopy /d /s /i /h /y "demos\hello\skin" "out\bin\skin\hello\"
xcopy /d /s /i /h /y "demos\sdtool\skin" "out\bin\skin\sdtool\"
xcopy /d /s /i /h /y "demos\testlua\skin" "out\bin\skin\testlua\"
xcopy /d /s /i /h /y "demos\testlua\lua" "out\bin\lua\testlua\"

goto END

::运行demo
:RUN
out\bin\%2.exe

:END